﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.IO.Packaging;
using System.Xml;
using System.Xml.Linq;

namespace ReporterEngine
{
    public class ReportPackage
    {
       public static XDocument GetTestDocumentFile(Stream filestream)
       {
           var result = new XDocument();

           using (Package package = Package.Open(filestream))
           {
               //var parts = package.GetParts().ToList();

               var documentPart = package.GetPart(new Uri("/word/document.xml", UriKind.Relative));

               using (var stream1 = documentPart.GetStream())
               {
                   XmlReader sr = XmlReader.Create(stream1);
                   result = XDocument.Load(sr);

                   sr.Close();
                   stream1.Close();
               }
           }

           return result;
       }
    }
}
